package org.wtfbbq.net.wifi;

import java.util.regex.*;
import java.util.*;
import java.io.*;

/**
 * Not finished
 *
 */ 
public abstract class RegexNetshHandler extends RadarHandler {
	public ArrayList<WirelessNetwork> wirelessNetworks() {
		try {
			Process proc = Runtime.getRuntime().exec("netsh wlan show networks mode=bssid");
			InputStreamReader isr = new InputStreamReader ( proc.getInputStream() );
			int buf;
			String text = "";
			while ( ( buf = isr.read() ) != -1 ) {
				text += (char)buf;
			}
		} catch ( Exception e ) {
		
		}
		return null;
	}
}
/*
import java.util.regex.*;
import java.util.List;
import java.util.ArrayList;
import java.io.*;

public class RegTest {

	public static void main(String[] args)
	{
		Pattern p = Pattern.compile("BSSID .*: (.*)\n.*Signal.*: ([0-9]{2})%.*\n.*Radio type.*: (.*)\n", Pattern.MULTILINE);
		String text = RegTest.getContents(new File("netsh wifi dump.txt"));
		List bssid1s = RegTest.getMatches(p, text, 1);
		List signalstrenghts = RegTest.getMatches(p, text, 2);
		List radiotypes = RegTest.getMatches(p, text, 3);


		for (int i=0; i< bssid1s.size(); i++)
		{
			System.out.print( bssid1s.get(i) + ": " );
			System.out.print( signalstrenghts.get(i) + "% " );
			System.out.println( "(" + radiotypes.get(i) + ")" );
		}
	}

	public static List getMatches(Pattern pattern, String text, int groupnumber) {
		List matches = new ArrayList();
		Matcher m = pattern.matcher(text);
		int index = 0;
		while(m.find(index)) {
			matches.add(m.group(groupnumber).trim());
			index = m.end();
		}
		return matches;
	}


	public static String getContents(File aFile) {
		//...checks on aFile are elided
		StringBuilder contents = new StringBuilder();

		try {
			//use buffering, reading one line at a time
			//FileReader always assumes default encoding is OK!
			BufferedReader input =  new BufferedReader(new FileReader(aFile));
			try {
				String line = null; //not declared within while loop

			while (( line = input.readLine()) != null){
				contents.append(line + "\n");
				//contents.append(System.getProperty("line.separator"));
			}
		}
		finally {
			input.close();
		}
	}
	catch (IOException ex){
		ex.printStackTrace();
	}

	return contents.toString();
}


}
*/